﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dados.DSMPTUDOTableAdapters;

namespace Dados
{
    public class AlbumDAL
    {
        static T_ALBUMTableAdapter albumTA = new T_ALBUMTableAdapter();

        public static DSMPTUDO.T_ALBUMDataTable ConsultaTodos()
        {
            try
            {
                return albumTA.GetData();
            }
            catch (Exception ex) 
            {
                throw new Exception(ex.Message);
            }          
        }

        public static DSMPTUDO.T_ALBUMDataTable ConsultaPorCodigo(int codigo) 
        {
            try
            {
                return albumTA.GetAlbumPorCodigo(codigo);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message); 
            }
        }

        public static bool Insere(string nome, int ano, string usuario)
        {
            try
            {
                return (albumTA.Insert(nome, ano, usuario) == 1);
                     
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public static bool Atualiza(string nome, int ano, string usuario, int codigo)
        {
            try
            {
                return (albumTA.Update(nome, ano, usuario, codigo, codigo) == 1);

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public static bool Remove(int codigo)
        {
            try
            {
                return (albumTA.Delete(codigo) == 1);
                     
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
}